package ifmo.group5512.util;

import ifmo.group5512.util.ComplexityOfOrder;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class ComplexityOfOrderService {
    public static void sortOrders(List<ComplexityOfOrder> complexityOfOrder) {
        Collections.sort(complexityOfOrder,
                new Comparator<ComplexityOfOrder>() {
                    @Override
                    public int compare(ComplexityOfOrder complexityOfOrder1, ComplexityOfOrder complexityOfOrder2) {
                        if (complexityOfOrder1.getPenalty()/complexityOfOrder1.getComplexity() <
                                complexityOfOrder2.getPenalty()/complexityOfOrder2.getComplexity()) {
                            return -1;
                        } else if (complexityOfOrder1.getPenalty()/complexityOfOrder1.getComplexity() >
                                complexityOfOrder2.getPenalty()/complexityOfOrder2.getComplexity()) {
                            return 1;
                        } else {
                            return 0;
                        }
                    }
                });
    }
}
